<%@ page contentType="text/html;charset=utf-8" language="java"%>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%> 
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<html:html>
<head>
		<META http-equiv=Content-Type content="text/html; charset=utf-8">
		<LINK href="../styles/stylewang.css"  type=text/css rel=stylesheet>
		<LINK href="styles/stylewang.css"  type=text/css rel=stylesheet>
		<LINK href="xtree.css"  type=text/css rel=stylesheet>
		<style type="text/css"></style>
		<title>CGProject</title>
		<html:base/>
</head>

<%String id = (String)request.getAttribute("ID");%>
<%String taskId = (String)request.getAttribute("TaskID");%>
<body>
<table border="0" width="100%" cellspacing="0" id="table6">
	<tr>
		<td height="25" align="left" bgcolor="#EEF2F7" colspan="7" width="85%">&nbsp;
		<b><bean:message key="make"/>&nbsp;<font color="#990000"><bean:write name="Make" property="makeName"/></font>&nbsp; <bean:message key="make.information"/></b>
		</td>
	</tr>
	<logic:equal name="NoTask" value="false"><tr>
		<td height="25" align="left" width="15%" style="border-right:1px dotted #C0C0C0; border-bottom:1px dotted #C0C0C0; font-family:Verdana; font-size:11px">
		<b>&nbsp; <bean:message key="taskname"/></b></td>	
		<td height="25" align="left" width="30%" style="border-right:1px dotted #C0C0C0; border-bottom:1px dotted #C0C0C0; font-family:Verdana; font-size:11px">
		<b>&nbsp; <bean:message key="taskdes"/></b></td>	
		<td height="25" align="left" width="10%" style="border-right:1px dotted #C0C0C0; border-bottom:1px dotted #C0C0C0; font-family:Verdana; font-size:11px">
		<b>&nbsp; <bean:message key="producer"/></b></td>
		<td height="25" align="left" width="10%" style="border-right:1px dotted #C0C0C0; border-bottom:1px dotted #C0C0C0; font-family:Verdana; font-size:11px">
		<b>&nbsp; <bean:message key="task.status"/></b></td>	
		<td height="25" align="left" width="8%" style="border-right:1px dotted #C0C0C0; border-bottom:1px dotted #C0C0C0; font-family:Verdana; font-size:11px">
		<b>&nbsp;<bean:message key="expectedhours"/></b></td>	
		<td height="25" align="left" width="53%" style="border-right:1px dotted #C0C0C0; border-bottom:1px dotted #C0C0C0; font-family:serif; font-size:11px">
		<b><font face="Verdana">&nbsp; </font></b></td>		
	</tr></logic:equal>
	<logic:equal name="NoTask" value="True"><tr>
		<td height="25" align="left" width="15%" style=" border-bottom:1px dotted #C0C0C0; font-family:Verdana; font-size:11px">
		&nbsp;<font color="#990000"><bean:message key="task.notask"/></font></td>		
		<td height="25" align="left" width="53%" style="border-right:1px dotted #C0C0C0; border-bottom:1px dotted #C0C0C0; font-family:serif; font-size:11px">
		　</td>		
	</tr></logic:equal>
	<logic:iterate id="element" name="Tasks">
	<logic:equal name="element" property="taskId" value="<%=taskId%>">
	<html:form action="/modTask">
	<html:hidden property="id"/>
	<tr>
		<td height="25" align="left" width="15%" style="border-right:1px dotted #C0C0C0; border-bottom:1px dotted #C0C0C0; font-family:Verdana; font-size:11px">
		&nbsp;&nbsp;<html:text property="name" size="20"/></td>
		<td height="25" align="left" width="30%" style="border-right:1px dotted #C0C0C0; border-bottom:1px dotted #C0C0C0; font-family:Verdana; font-size:11px">
		&nbsp;&nbsp;<html:text property="description" size="30"/></td>	
		<logic:equal name="Flag"  value="able">
		<td height="25" align="left" width="10%" style="border-right:1px dotted #C0C0C0; border-bottom:1px dotted #C0C0C0; font-family:Verdana; font-size:11px">
		&nbsp;&nbsp;<html:select property="reguser" style="border:1px solid #C0C0C0; font-family: Tahoma; font-size: 11px">
				<html:option value=""></html:option>
				<html:options  collection="Regusers"
							   property="regUserId"
							   labelProperty="regName"/>
			</html:select></td>
		</logic:equal>
		<logic:equal name="Flag" value="disable">
		<td height="25" align="left" width="10%" style="border-right:1px dotted #C0C0C0; border-bottom:1px dotted #C0C0C0; font-family:Verdana; font-size:11px">
		&nbsp;&nbsp;<html:select property="reguser" disabled="true" style="border:1px solid #C0C0C0; font-family: Tahoma; font-size: 11px">
				<html:option value=""></html:option>
				<html:options  collection="Regusers"
							   property="regUserId"
							   labelProperty="regName"/>
			</html:select></td>
		</logic:equal>		
		<td height="25" align="left" width="10%" style="border-right:1px dotted #C0C0C0; border-bottom:1px dotted #C0C0C0; font-family:Verdana; font-size:11px">
		&nbsp;&nbsp;
		<script language=javascript>
			var s=top.changeColor("<bean:write name="element" property="status.statusDisplay"/>");
			document.write(s);
		</script>
		</td>	
		<td height="25" align="left" width="8%" style="border-right:1px dotted #C0C0C0; border-bottom:1px dotted #C0C0C0; font-family:Verdana; font-size:11px">
		&nbsp;&nbsp;<html:text property="expectHours" size="5"/></td>	
		
		<td height="25" align="left" width="53%" style="border-right:1px dotted #C0C0C0; border-bottom:1px dotted #C0C0C0; font-family:serif; font-size:11px">
		&nbsp;<input type="button" value="Modify" name="B2" style="font-family: Tahoma; font-size: 11px" onClick="submitModTask()">
&nbsp;&nbsp;</td>		
	</tr>
	</html:form>
	</logic:equal>
	<logic:notEqual name="element" property="taskId" value="<%=taskId%>">
	<tr>
		<td height="25" align="left" width="15%" style="border-right:1px dotted #C0C0C0; border-bottom:1px dotted #C0C0C0; font-family:Verdana; font-size:11px">
		&nbsp;&nbsp;<bean:write name="element" property="taskName"/></td>
		<td height="25" align="left" width="30%" style="border-right:1px dotted #C0C0C0; border-bottom:1px dotted #C0C0C0; font-family:Verdana; font-size:11px">
		&nbsp;&nbsp;<bean:write name="element" property="taskDescription"/></td>
		<td height="25" align="left" width="10%" style="border-right:1px dotted #C0C0C0; border-bottom:1px dotted #C0C0C0; font-family:Verdana; font-size:11px">
		&nbsp;&nbsp;<logic:notEmpty name="element" property="reguser"><bean:write name="element" property="reguser.regName"/></logic:notEmpty></td>
		<td height="25" align="left" width="10%" style="border-right:1px dotted #C0C0C0; border-bottom:1px dotted #C0C0C0; font-family:Verdana; font-size:11px">
		&nbsp;&nbsp;
		<script language=javascript>
			var s=top.changeColor("<bean:write name="element" property="status.statusDisplay"/>");
			document.write(s);
		</script>
		</td>	
		<td height="25" align="left" width="8%" style="border-right:1px dotted #C0C0C0; border-bottom:1px dotted #C0C0C0; font-family:Verdana; font-size:11px">
		&nbsp;&nbsp;<bean:write name="element" property="exceptHours"/></td>	
		
		<td height="25" align="left" width="53%" style="border-right:1px dotted #C0C0C0; border-bottom:1px dotted #C0C0C0; font-family:serif; font-size:11px">
		&nbsp;<html:link page="/makeIndex.do" paramId="taskId" paramName="element" paramProperty="taskId">[<bean:message key="modify"/>]</html:link>&nbsp;&nbsp;
		<a href="../del.do?FatherType=Make&FatherId=<%=id%> &Type=Task&Id=<bean:write name="element" property="taskId"/>" onclick="return   confirm('ConfirmDelete')">[<bean:message key="delete"/>]</a></td>		
	</tr>
	</logic:notEqual>
	</logic:iterate>
</table>
<html:form action="/addTask">
<html:hidden property="id" value="<%=id%>"/>
<table border="0" width="110%" cellspacing="0" id="tabletable" height="59" cellpadding="0">
	<tr>
		<td height="25" width="10%"align="left" bgcolor="#EEF2F7" style="border-left:1px dotted #C0C0C0; border-right:1px dotted #C0C0C0; border-bottom:1px dotted #C0C0C0; font-family:Tahoma; font-size:11px">&nbsp;
		<font color="#990000"><bean:message key="task.addtask"/></font>
		</td>
		<td height="25" width="17%" bgcolor="#EEF2F7" style="border-right:1px dotted #C0C0C0; border-bottom:1px dotted #C0C0C0; font-family:Tahoma; font-size:11px"><bean:message key="taskname"/></td>
		<td height="25" width="35%" bgcolor="#EEF2F7" style="border-right:1px dotted #C0C0C0; border-bottom:1px dotted #C0C0C0; font-family:Tahoma; font-size:11px"><bean:message key="taskdes"/></td>
		<td height="25" width="20%" bgcolor="#EEF2F7" style="border-right:1px dotted #C0C0C0; border-bottom:1px dotted #C0C0C0; font-family:Tahoma; font-size:11px"><bean:message key="producer"/></td>		
		<td height="25" width="30%" bgcolor="#EEF2F7" style="border-right:1px dotted #C0C0C0; border-bottom:1px dotted #C0C0C0; font-family:Tahoma; font-size:11px"><bean:message key="expectedhours"/></td>
	</tr>
	<tbody id="tbDetailUsed">
	<tr>
		<td height="20" width="10%" style="border-left:1px dotted #C0C0C0; border-right:1px dotted #C0C0C0; border-bottom:1px dotted #C0C0C0; font-family:Tahoma; font-size:11px" align="center"><input type="checkbox"  disabled name="record_select" ></td>
		<td height="20" width="17%" style="border-right:1px dotted #C0C0C0; border-bottom:1px dotted #C0C0C0; ">
		<html:text property="name" size="40" style="border:1px solid #FFFFFF; font-family: Tahoma; font-size: 11px; padding-left:4px; padding-right:4px; padding-top:1px; padding-bottom:1px"/></td>
		<td height="20" width="35%" style="border-right:1px dotted #C0C0C0; border-bottom:1px dotted #C0C0C0; ">
		<html:text property="dexcription" size="40" style="border:1px solid #FFFFFF; font-family: Tahoma; font-size: 11px; padding-left:4px; padding-right:4px; padding-top:1px; padding-bottom:1px"/></td>
		<td height="20" width="20%"  style="border-right:1px dotted #C0C0C0; border-bottom:1px dotted #C0C0C0; font-family:Tahoma; font-size:11px">
		<html:select property="reguser" style="border:1px solid #C0C0C0; font-family: Tahoma; font-size: 11px">
				<html:option value=""></html:option>
				<html:options  collection="Regusers"
							   property="regUserId"
							   labelProperty="regName"/>
			</html:select></td>
		<td height="20" width="30%" style="border-right:1px dotted #C0C0C0; border-bottom:1px dotted #C0C0C0; ">
		<html:text property="expectHours" size="10" style="border:1px solid #FFFFFF; "/></td>
	</tr>	
	</tbody>
	<tr>
			<td height="20" width="110%" style="border-left:1px dotted #C0C0C0; border-right:1px dotted #C0C0C0; border-bottom:1px dotted #C0C0C0; font-family:Tahoma; font-size:11px" colspan="5">
			<input type="button" value="Submit" name="B1" style="font-family: Tahoma; font-size: 11px" onClick="submitAddTask()">
			&nbsp;&nbsp;&nbsp;&nbsp;
			<input type="button"  value="IncreaseClause" onClick="addDetailProcess();" style="font-family: Tahoma; font-size: 11px">
			<input type="button" value="DeleteClause" style="font-family: Tahoma; font-size: 11px" onClick="delDetailProcess()"></td>
		</tr>
	</table>
	<table id="tbDetailPrepare" style="display:none" cellspacing="0" cellpadding="0">
		<tr>
			<td height="20" width="10%" style="border-left:1px dotted #C0C0C0; border-right:1px dotted #C0C0C0; border-bottom:1px dotted #C0C0C0; font-family:Tahoma; font-size:11px" align="center"><input type="checkbox"  name="record_select" ></td>
			<td height="20" width="17%" style="border-right:1px dotted #C0C0C0; border-bottom:1px dotted #C0C0C0; ">
			<html:text property="name" size="40" style="border:1px solid #FFFFFF; font-family: Tahoma; font-size: 11px; padding-left:4px; padding-right:4px; padding-top:1px; padding-bottom:1px"/></td>
			<td height="20" width="35%" style="border-right:1px dotted #C0C0C0; border-bottom:1px dotted #C0C0C0; ">
			<html:text property="dexcription" size="40" style="border:1px solid #FFFFFF; font-family: Tahoma; font-size: 11px; padding-left:4px; padding-right:4px; padding-top:1px; padding-bottom:1px"/></td>
			<td height="20" width="20%" style="border-right:1px dotted #C0C0C0; border-bottom:1px dotted #C0C0C0; font-family:Tahoma; font-size:11px">
			<html:select property="reguser" style="border:1px solid #C0C0C0; font-family: Tahoma; font-size: 11px">
					<html:option value=""></html:option>
					<html:options  collection="Regusers"
								   property="regUserId"
								   labelProperty="regName"/>
				</html:select></td>
			<td height="20" width="30%" style="border-right:1px dotted #C0C0C0; border-bottom:1px dotted #C0C0C0; ">
			<html:text property="expectHours" size="10" style="border:1px solid #FFFFFF; "/></td>
		</tr>	

	</table>
	


</html:form>
</body>
</html:html>
<script language="javascript">
function submitModTask()
{
	if(document.modTaskForm.name.value=="")
	{
		alert("Please input TaskName");
		return;
	}	
	document.modTaskForm.submit();
}



function submitAddTask()
{
	var counter=tbDetailUsed.rows;
	var wrong_counter1=0;
	var wrong_counter2=0;
	for(var i=0;i<counter.length;i++)
	{
		if(document.addTaskForm.name[i].value=="")
		{
			alert("Please input "+(i+1)+"'s name");
			wrong_counter1++;
			break;
		}
	}
	for(var j=0;j<counter.length;j++)
	{
		for(var k=j;k<counter.length;k++)
		{
			if(document.addTaskForm.name[j].value==document.addTaskForm.name[k].value&&j!=k&&wrong_counter1==0)
			{
				alert(""+(j+1)+" and "+(k+1)+" cannot be the same name");
				wrong_counter2++;
				break;
			}

		}
	}
	if(wrong_counter1!=0||wrong_counter2!=0)
	{
		return;
	}
	document.addTaskForm.submit();
}

function addDetailProcess(afterRowIndex)		//增加明细
{
	
	
	var alltbDetailUsed = document.all("tbDetailUsed").rows;
	
	var theFirstSelectedDetail;
	if (afterRowIndex==null)
	{
	  theFirstSelectedDetail=alltbDetailUsed.length-2;
	}
	else theFirstSelectedDetail=afterRowIndex;
	var newRow = document.all("tbDetailPrepare").rows[0].cloneNode(true);
	var desRow = alltbDetailUsed[theFirstSelectedDetail+1];
//		desRow.parentElement.insertBefore(newRow,desRow );
	desRow.parentElement.appendChild(newRow);
	
	return alltbDetailUsed.length;
}

function delDetailProcess()						//删除明细
{
	var tag="";
	var alltbDetailUsed = document.all("tbDetailUsed").rows;
	for(var ii=0;ii<alltbDetailUsed.length;ii++)
	{
		
		if (alltbDetailUsed[ii].all("record_select").checked==true)
		{
			tag="true";
			break;		
		}
		else
		{
			tag="false";
		}
	}
	if(tag=="false")
	{
		alert("Please select a clause");
	}
	else
	{
		for(var i=0;i<alltbDetailUsed.length;i++)
		{
			if (alltbDetailUsed[i].all("record_select").checked==true)
			{
				document.all("tbDetailUsed").deleteRow(i);
				i=i-1;
			}
		}
	}
}

</script>
